<%--
  Created by IntelliJ IDEA.
  User: Lanan
  Date: 2017/12/19 0019
  Time: 16:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<html>
<head>
    <%@ include file="/commons/basejs.jsp" %>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户常用联系人管理</title>
</head>
<body>
<table id="user_examination_population_datagrid" title="用户账户信息列表" class="easyui-datagrid"
       data-options="
   		url:'${path}/user/examination/population/list.do',
		fit:true,
		idField:'id',
		rownumbers:true,
		toolbar:'#tools',
		loadMsg:'正在处理，请等待......',
		pagination:true,
		fitColumns:true,
		singleSelect:true,
		nowrap:false,
   		">
    <thead>
    <th data-options="field:'id', align:'center', checkbox:true">ID</th>
    <th data-options="field:'userName', align:'center'">用户名</th>
    <th data-options="field:'userPhone', align:'center'">用户电话</th>
    <th data-options="field:'userEmail', align:'center'">用户邮箱</th>
    <th data-options="field:'name', align:'center'">常用体检人</th>
    <th data-options="field:'phone', align:'center'">常用体检人电话</th>
    <th data-options="field:'age', align:'center'">常用体检人年龄</th>
    <th data-options="field:'sex', align:'center', formatter:formatSex">常用体检人性别</th>
    <th data-options="field:'identity', align:'center'">常用体检人省份证号</th>
    <th data-options="field:'def', align:'center', formatter:formatDef">是否默认</th>
    <th data-options="field:'createTime', align:'center', formatter:formatDatebox">创建时间</th>
    <th data-options="field:'updateTime', align:'center', formatter:formatDatebox">更新时间</th>
    </thead>
</table>
<div id="tools">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="refreshUserExaminationPopulationList()">刷新</a>

    <shiro:hasPermission name="/user/examination/population/insert.do">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="openAddUserExaminationPopulationBox()">添加</a>
    </shiro:hasPermission>
    <shiro:hasPermission name="/user/examination/population/update.do">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick="openUpdateUserExaminationPopulationBox()">修改</a>
    </shiro:hasPermission>
    <shiro:hasPermission name="/user/examination/population/delete.do">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove'" onclick="deleteUserExaminationPopulation()">删除</a>
    </shiro:hasPermission>

    <form action="#" id="searchForm">
        <label>用户:</label>
        <div style="position: relative;height:15px;width:170px;top:2px; display:inline-block;">
            <input type="text" name="searchUserInfo" id="searchUserInfo" value="" hidden/>
            <input type="text" id="autocomplete-ajax-search" style="position: absolute; z-index: 2; background: transparent;"/>
            <input type="text" id="autocomplete-ajax-search-x" disabled="disabled" style="color: #CCC; position: absolute; background: transparent; z-index: 1;"/>
        </div>
        <label>常用联系人:</label>
        <input class="easyui-textbox" id="searchUserExaminationPopulation" name="searchUserExaminationPopulation" data-options="prompt:'请输入搜索关键字'"/>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchUserExaminationPopulation()">搜索</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear'" onclick="resetUserExaminationPopulation()">重置</a>
    </form>
</div>
<!-- 数据表格 end -->

<script type="text/javascript">

    $(function () {
        autoCompleteDate('${path}/user/address/autoCompleteData.do', 'autocomplete-ajax-search', 'searchUserInfo', 'autocomplete-ajax-search-x');
    })

    function formatDef(value) {
        if (value == 0) return '<span style="color:lightgrey">' + '否' + '</span>';
        else if (value == 1) return '<span style="color:black">' + '是' + '</span>';
    }

    function formatSex(value) {
        if (value == 0) return '<span style="color:deepskyblue">' + '男' + '</span>';
        else if (value == 1) return '<span style="color:hotpink">' + '女' + '</span>';
    }

    function refreshUserExaminationPopulationList() {
        $("#user_examination_population_datagrid").datagrid("reload");
    }

    function openAddUserExaminationPopulationBox() {
        $.modalDialog({
            title : '添加用户常用联系人信息',
            id : 'user_examination_population_insert',
            width : 500,
            height : 350,
            href : '${path}/user/examination/population/insert/index.do'
        })
    }

    function openUpdateUserExaminationPopulationBox() {
        var select = $("#user_examination_population_datagrid").datagrid("getSelected");
        if (select == null) {
            $.messager.alert("提示", "请选择要修改的用户常用联系人信息!", "info");
            return;
        }
        $.modalDialog({
            title : '修改用户常用联系人信息',
            id : 'user_examination_population_update',
            width : 500,
            height : 350,
            href : '${path}/user/examination/population/update/index.do?id=' + select.id
        })
    }

    function deleteUserExaminationPopulation() {
        lananDelete("user_examination_population_datagrid", "确定删除该用户常用联系人信息?", "${path}/user/examination/population/delete.do");
    }

    function searchUserExaminationPopulation() {
        var queryParams = {};
        queryParams.userId = $("#searchUserInfo").val();
        queryParams.searchKeyInfo = $("#searchUserExaminationPopulation").val();

        $("#user_examination_population_datagrid").datagrid('options').queryParams = queryParams;
        $("#user_examination_population_datagrid").datagrid('getPager').data("pagination").options.pageNumber = 1;
        var select = $('#user_examination_population_datagrid').datagrid('getSelected');
        if(select != null){
            $('#user_examination_population_datagrid').datagrid('clearSelections');
        }
        $("#user_examination_population_datagrid").datagrid('reload');
    }

    function resetUserExaminationPopulation() {
        $("#searchForm").form('clear');
    }

</script>

</body>
</html>
